package cn.edu.njust.filter;


import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpFilter;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

/**
 * token解析过滤器
 *
 * @author wangs
 * @date 2025/4/20 23:12
 * @since 2.0.0
 */
//@WebFilter("/*")
public class TokenFilter extends HttpFilter {
    @Override
    protected void doFilter(HttpServletRequest req, HttpServletResponse res, FilterChain chain) throws IOException, ServletException {

        String authorization = req.getHeader("authorization");
//        if (Objects.nonNull(authorization) && authorization.startsWith("Bearer ")) {
//            authorization = authorization.substring(7);
//            Token token = JSON.parseObject(authorization, Token.class);
//            if (Objects.nonNull(token)) {
//                User user = JSON.copyTo(token, User.class);
//                UserContext.setCurrentUser(user);
//            }
//        }
        chain.doFilter(req, res);
    }
}
